home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / Ebooks / Thinking in C++ V2 / C09 / Macro.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2000-05-25  |  570 b   |  23 lines

  1. //: C09:Macro.cpp
  2. // From Thinking in C++, 2nd Edition
  3. // Available at http://www.BruceEckel.com
  4. // (c) Bruce Eckel 1999
  5. // Copyright notice in Copyright.txt
  6. // Side effects with macros
  7. #include "../require.h"
  8. #include <fstream>
  9. using namespace std;
  10.  
  11. #define BAND(X) (((X)>5 && (X)<10) ? (X) : 0)
  12.  
  13. int main() {
  14.   ofstream out("macro.out");
  15.   assure(out, "macro.out");
  16.   for(int i = 4; i < 11; i++) {
  17.     int a = i;
  18.     out << "a = " << a << endl << '\t';
  19.     out << "BAND(++a)=" << BAND(++a) << endl;
  20.     out << "\t a = " << a << endl;
  21.   }
  22. } ///:~
  23.